<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>登录</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <!-------------jquery库-------------->
  	<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
  	
	<!-------------Amazeui--------------->
    <script type="text/javascript" src="js/amazeui.js"></script>
    <link rel="stylesheet" type="text/css" href="css/amazeui.css">
    <!------------核心样式-------------->
    <link rel="stylesheet" type="text/css" href="css/user.css"> 
	<script>
		//@ sourceURL=login_ajax.js
$(function(){
	
	//给form表单添加submit事件
	$("form").submit(function(){
		return login();
	});
	
});
function login(){
	//获取页面数据
	var userName=$("form input[name=passport]").val();
	var userPassword=$("form input[name=password]").val();
	if(userName==""){
		$("#passport_msg").text("手机号不能为空");
		return false;
	}
	if(userPassword==""){
		$("#password_msg").text("密码不能为空");
		return false;
	}

	$.ajax({
		url:"http://www.easymall.com/user/login",
		type:"get",
		data:{"userPhone":userName,"userPassword":userPassword},
		dataType:"json",
		success:function(result){
			//result是服务端返回的数据
			if(result.status==200){
				//window.location.href="index.html";
				window.location.href="index.html";
			}else{
				alert("登录失败");
			}
		},
		error:function(){
			alert("请求失败!");
		}
	});
	
	return false;
}


		
	</script>
	       
</head>
<body>

<!-------------------登录------------------->
<div id="log_register">
	
	<div class="lr_box">
		
		<div class="tag">
			<ul>
				<li><a class="cur" href="login.html">登录</a></li>
				<li><a href="register.html">注册</a></li>
				<div class="clear"></div>
			</ul>
		</div>
	<form>
		<table class="table_list">
			<tbody>
				<tr>
					<td><input class="text" name="passport" type="text" placeholder="手机号"></td>
					<td><span style="color: red" id="passport_msg"></span></td>
				</tr>
				<tr>
					<td><input class="text" type="password" name="password" placeholder="您的密码"></td>
					<td><span style="color: red" id="password_msg"></span></td>
				</tr>
				<tr>
					<td><input class="submit" type="submit" value="登录"></td>
				</tr>
			</tbody>
		</table>
</form>
	</div>

</div>

</body>
</html>